<?php

namespace App\Http\Controllers\Home;

use App\Http\Controllers\Controller;
use App\Http\Requests\LoginRequest;
use App\Models\User;
use Illuminate\Http\Request;

/**
 * Class AuthorizationController
 * 用户登入授权
 * @package App\Http\Controllers\Home
 */
class AuthorizationController extends AbsController
{
    /**
     * 用户登入
     * @param LoginRequest $request
     * @return \Illuminate\Contracts\Routing\ResponseFactory|\Illuminate\Http\Response
     */
    public function login(LoginRequest $request) {
        $credentials = $request->only('phone', 'password');
       if (\Auth::guard('web')->attempt($credentials)) {
           return  $this->success(\Auth::user(),'您好,欢迎回来');
       }else {
           return $this->error(401,'用户名或密码错误请重试');
       }
    }
}
